//
//  AppDelegate.swift
//  新浪微博
//
//  Created by mac on 16/5/19.
//  Copyright © 2016年 mac.com. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        registerNotification()

        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.backgroundColor = UIColor.whiteColor()
        window?.makeKeyAndVisible()
//        window?.rootViewController = LLHomeViewController()
        window?.rootViewController = defaultViewController()
    return true
    }
    private func defaultViewController() ->UIViewController {
        return LLUserAccountViewModel.sharedAccountViewModel.userLogin ?LLWelcomeViewController(): LLMainViewController()
    
    }
    private func registerNotification(){
    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("changeRootVc:"), name: SwitchRootViewController, object: nil)
    
    }
  @objc  private func changeRootVc(n:NSNotification){
        if n.object == nil {
            print(n)
        window?.rootViewController = LLWelcomeViewController()
        }else{
        window?.rootViewController = LLMainViewController()
        }
    
    
    }
    
    
    

}

